//
//  CommunityTableViewCell.m
//  NewChat
//
//  Created by lanou3g on 16/2/27.
//  Copyright © 2016年 蓝鸥. All rights reserved.
//

#import "CommunityTableViewCell.h"

//定义宏，用来cell布局
#define kWidth self.contentView.frame.size.width
#define kHeight self.contentView.frame.size.height

@implementation CommunityTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.backgroundColor = [UIColor whiteColor];
        
        [self addAllViews];
        
    }
    return self;
}


#pragma mark---------添加子控件-------------

-(void)addAllViews{
    
    [self addSubview:self.imaV];
    [self addSubview:self.titleLbl];
    [self addSubview:self.introduceLbl];
    [self addSubview:self.numberLbl];
    
}


#pragma mark----------根据父视图自适应------

-(void)layoutSubviews{
    [super layoutSubviews];
    _imaV.frame = CGRectMake(kWidth*0.05, kHeight*0.1, kHeight*0.8, kHeight*0.8);
    //设置圆角
    _imaV.layer.cornerRadius = kHeight*0.4;
    _imaV.layer.masksToBounds = YES;
    
    _titleLbl.frame = CGRectMake(kWidth*0.27, kHeight*0.05, kWidth*0.3, kHeight*0.4);
    _introduceLbl.frame = CGRectMake(kWidth*0.27, kHeight*0.5, kWidth*0.45, kHeight*0.4);
    _numberLbl.frame = CGRectMake(kWidth*0.75, kHeight*0.3, kWidth*0.2, kHeight*0.4);
}

#pragma mark----------懒加载子载控件----------

-(UIImageView *)imaV{
    if (!_imaV) {
        _imaV = [[UIImageView alloc]init];
        _imaV.frame = CGRectMake(kWidth*0.01, kHeight*0.01, kWidth*0.1, kHeight*0.8);
        _imaV.backgroundColor = [UIColor cyanColor];
    }
    return _imaV;
}

-(UILabel *)titleLbl{
    if (!_titleLbl) {
        _titleLbl = [[UILabel alloc]init];
        _titleLbl.frame = CGRectMake(kWidth *0.15, kHeight*0.01, kWidth*0.2, kHeight*0.4);
        _titleLbl.backgroundColor = [UIColor whiteColor];
        _titleLbl.font = [UIFont systemFontOfSize:22];
        _titleLbl.textColor = [UIColor magentaColor];
    }
    return _titleLbl;
    
}

-(UILabel *)introduceLbl{
    
    if (!_introduceLbl) {
        _introduceLbl = [[UILabel alloc]init];
        _introduceLbl.frame = CGRectMake(kWidth*0.15, kHeight*0.22, kWidth*0.2, kHeight*0.4);
        _introduceLbl.backgroundColor = [UIColor whiteColor];
    }
    
    return _introduceLbl;
}

-(UILabel *)numberLbl{
    
    if (!_numberLbl) {
        _numberLbl = [[UILabel alloc]init];
        _numberLbl.frame = CGRectMake(kWidth*0.7, kHeight*0.01, kWidth*0.2, kHeight*0.8);
        _numberLbl.backgroundColor = [UIColor whiteColor];
    }
    
    return _numberLbl;
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
